package com.gel.codegeneration.core.handler;

import com.gel.codegeneration.ai.model.enums.CodeGenTypeEnum;
import com.gel.codegeneration.model.entity.User;
import com.gel.codegeneration.service.ChatHistoryService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;

/**
 * @BelongsProject: code-generation-platform
 * @BelongsPackage: com.gel.codegeneration.core.handler
 * @Author: gel
 * @CreateTime: 2025-08-24  18:21
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class StreamHandlerExecutor {
    @Resource
    private JsonMessageStreamHandler jsonMessageStreamHandler;


    public Flux<String> doExecute(Flux<String> originFlux, ChatHistoryService chatHistoryService, Long appId,User loginUser,CodeGenTypeEnum codeGenType){
        return switch (codeGenType){
            case VUE_PROJECT -> jsonMessageStreamHandler.handle(originFlux,chatHistoryService,appId,loginUser);
            case HTML,MULTI_FILE ->
                new SimpleTextStreamHandler().handle(originFlux,chatHistoryService,appId,loginUser);

        };

    }
}
